package com.kuang;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RequestDispatcherServlet extends HttpServlet {
//    请求这个Servlet转发到GetParamServlet这个Servlet
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        doGet(req, resp);
      ServletContext context=this.getServletContext();
//      RequestDispatcher dispatcher=context.getRequestDispatcher("/getParam");
//      dispatcher.forward(req,resp);
      context.getRequestDispatcher("/getParam").forward(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
